package problemLCR018;

//LCR 018. 验证回文串
//https://leetcode.cn/problems/XltzEq/

class Solution {
    public boolean isPalindrome(String _s) {
        char[] s = _s.toCharArray();
        StringBuffer str = new StringBuffer();
        for(int i = 0; i<s.length; i++) {
            if(Character.isDigit(s[i])) str.append(s[i]);
            if(Character.isAlphabetic(s[i])) str.append(Character.toLowerCase(s[i]));
        }
        for(int i = 0, j = str.length()-1; i<j; i++, j--) {
            if(str.charAt(i) != str.charAt(j)) return false;
        }
        return true;
    }
}